﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.IO;

namespace AP.LUNA.Commons
{
    public class Utils
    {
        public static void WriteLine(string line, string fileName)
        {
            using (TextWriter writer = new StreamWriter(fileName, true))
            {
                writer.WriteLine(line);
            }
        }
        public static void WriteError(string source, Exception exception)
        {
            HttpContext context = HttpContext.Current;
            string path=Path.Combine(context.Server.MapPath("./Logs"),string.Format("LUNALog_{0}.txt",DateTime.Now.ToString("yyyyMMdd")));
            WriteLine(string.Format("[{0}][{1}]---------------------------------",source,DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")),path);
            WriteLine(exception.ToString(),path);
            WriteLine("------------------------------------------------",path);
        }
    }
}
